package com.hxd.otc.module.my.presenter;

import android.support.annotation.NonNull;

import com.hxd.otc.base.BaseBean;
import com.hxd.otc.module.my.contract.StableCurrencyContract;
import com.hxd.otc.module.my.model.UserModel;
import com.hxd.otc.module.order.bean.StableCurrencyBean;
import com.hxd.otc.mvp.base.BasePresenter;
import com.hxd.otc.net.BaseObserver;

/**
 * 包  名 :  com.example.administrator.blocksbankclient.mvp.order
 * 类  名 :  OrderPresenter
 * 作  者 :  zjl
 * 时  间 :  2018/6/4 17:02
 * 描  述 :  ${TODO}所有订单页面P
 */
public class StableCurrencyPresenter extends BasePresenter<StableCurrencyContract.View> implements StableCurrencyContract.Presenter {

    UserModel userModel;

    public StableCurrencyPresenter(StableCurrencyContract.View view) {
        super(view);
        userModel = UserModel.getInstance();
    }

    @Override
    public void start() {

    }


    @Override
    public void doLoadData() {
        userModel.getStableCurrencyList(new BaseObserver<StableCurrencyBean>() {
            @Override
            public void onNext(String title, @NonNull StableCurrencyBean bean) {
                doSetAdapter(bean);
            }

            @Override
            public void onError(int errType, String errMessage) {
                mView.onError(errType);
                mView.showToast(errMessage);
                doShowNoMore();
            }

        }, mView.<BaseBean<StableCurrencyBean>>bindAutoDispose());

    }


    @Override
    public void doShowNoMore() {
        mView.onShowNoMore();
    }

    @Override
    public void doSetAdapter(StableCurrencyBean bean) {

        mView.onSetAdapter(bean);
        mView.onShowNoMore();
    }


}
